﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Qiang.Geometry
{
    public class MultiPolygon : MultiSurface, IMultiPolygon
    {





        #region 属性


        IList<IPolygon> _polygons;

        /// <summary>
        /// 
        /// </summary>
        public IList<IPolygon> Polygons
        {
            get { return _polygons; }
            set { _polygons = value; }
        }

        /// <summary>
        /// 多边形数量。
        /// </summary>
        public int NumGeometries
        {
            get { return _polygons.Count; }
        }


        /// <summary>
        /// 图形类型。
        /// </summary>
        public override GeometryType GeometryType
        {
            get { return GeometryType.MultiPolygon; }
        }

        /// <summary>
        /// 坐标集合。
        /// </summary>
        public override IList<Coordinate> Coordinates
        {
            get
            {
                List<Coordinate> coors = new List<Coordinate>();
                foreach (IPolygon polygon in _polygons)
                {
                    coors.AddRange(polygon.Coordinates);
                }
                return coors;
            }
            set
            {
                if (value == null || value.Count < 3) return;
                _polygons.Clear();
                Add(new Polygon(value));
            }
        }

        /// <summary>
        /// 是否为空。
        /// </summary>
        public override bool IsEmpty
        {
            get 
            {
                foreach (IPolygon polygon in _polygons)
                {
                    if (polygon.IsEmpty == false) return false;
                }
                return true;
            }
        }


        #endregion


        #region 方法


        public void Add(IPolygon polygon)
        { 
        }


        #endregion



        #region IEnumerable成员函数

        public IEnumerator GetEnumerator()
        {
            return _polygons.GetEnumerator();
        }


        #endregion


    }
}
